<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IndexPayload>" %>
<%@ Import Namespace="ActivateYourGlutes.Payloads.Account"%>
<%@ Import Namespace="ActivateYourGlutes.Services.Model"%>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Your Account
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<%
    var localeSettings = ViewData.Model.LocaleSettings;
    var dateFormat = localeSettings.DateFormat;
    var jqueryDateFormat = localeSettings.JQueryDateFormat;
%>
<script type="text/javascript">
jQuery.validator.setDefaults({
    debug: false,
    success: "valid"
});
</script>
<script type="text/javascript">
  $(document).ready(function() {
      $("#entryForm").validate({
          rules: {
              Email: {
                  required: true,
                  email: true
              },
              DateOfBirth: {
                required: true
              }
          }
      });
      
      $("#DateOfBirth").datepicker({ defaultDate: 0, dateFormat: '<%= jqueryDateFormat %>' });
  });
</script>

    <%= Html.ValidationSummary() %>
    <% using (Html.BeginForm(null, null, null, FormMethod.Post, new { id = "entryForm" }))
       { %>
    <%= Html.AntiForgeryToken() %>
    <div id="subheader">
        <h2>Your Profile</h2>
        <div>            
            <%= Html.ActionLink("Change Password", MVC.Account.ChangePassword()) %>
            <%= Html.ActionLink("Manage Measurement Types", MVC.MeasurementType.Index()) %>
        </div>
    </div>
    <% if (ViewData.Model.Success != null)
{
%>
    <p class="success"><%= ViewData.Model.Success %></p>        
<%
}
%>
    <fieldset>
        <table>
            <tr>
                <td><label for="EntryDate">Email</label></td>
                <td><%= Html.TextBox("Email", ViewData.Model.Email)%></td>
            </tr>
            <tr>
                <td><label for="DateOfBirth">Date of Birth</label></td>
                <td><%= Html.TextBox("DateOfBirth", ViewData.Model.Account.DateOfBirth.ToString(dateFormat))%></td>
            </tr>
            <tr>
                <td><label for="UnitsForLength">Units For Length</label></td>
                <td><%= Html.DropDownList("UnitForLengthId", ViewData.Model.UnitsOfLength)%></td>
            </tr>
            <tr>
                <td><label for="UnitsForWeight">Units For Weight</label></td>
                <td><%= Html.DropDownList("UnitForWeightId", ViewData.Model.UnitsOfWeight)%></td>
            </tr>
        </table>
    </fieldset>
    <div>
        <h2>Key Indicators</h2>        
    </div>
    
    <% Html.RenderPartial(MVC.Shared.Views.HorizontalMeasurementTypes, ViewData.Model.HorizontalMeasurementTypesPayload); %>
    
    <p>
        <input type="submit" value="Save Changes" />
    </p>
    <% } %>
</asp:Content>
